package com.zhongxi.guoyuan.adapter.rewardCoin;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import com.zhongxi.guoyuan.fragment.hmfragment.HMBestPriceFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.HMNewCateFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.HMSalesGoodsFragment;
import com.zhongxi.guoyuan.view.rewardCoin.ItemHMFragmentFactory;

/**
 * Created by Administrator on 2017/10/12.
 */

public class HMCateAdapter extends FragmentStatePagerAdapter {
    private String trim;
    private String id;

    public HMCateAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        String title = "最新";
        switch (position) {
            case 0:
                title = "最新";
                break;
            case 1:
                title = "销量";
                break;
            case 2:
                title = "最惠";
                break;
        }
        return title;
    }

    @Override
    public Fragment getItem(int position) {
        System.out.println("trim22==" + trim);
        return ItemHMFragmentFactory.create(position, id, trim);
    }

//    @Override
//    public Object instantiateItem(ViewGroup container, int position) {
//        if (position == 0) {
//            HMNewCateFragment hmNewCateFragment = (HMNewCateFragment) super.instantiateItem(container, position);
////            hmNewCateFragment.setUpdatePrimary(id, trim);
//            return hmNewCateFragment;
//        } else if (position == 1) {
//            HMSalesGoodsFragment hmSalesGoodsFragment = (HMSalesGoodsFragment) super.instantiateItem(container, position);
////            hmSalesGoodsFragment.setUpdatePrimary(id, trim);
//            return hmSalesGoodsFragment;
//        } else if (position == 2) {
//            HMBestPriceFragment hmBestPriceFragment = (HMBestPriceFragment) super.instantiateItem(container, position);
////            hmBestPriceFragment.setUpdatePrimary(id, trim);
//            return hmBestPriceFragment;
//        }
//        return super.instantiateItem(container, position);
//    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    public void setItemPrimary(String id, String trim) {
        this.id = id;
        this.trim = trim;
    }
}
